package com.student.education.controller;

import com.student.education.common.CommonPage;
import com.student.education.common.CommonResult;
import com.student.education.entity.CheckWork;
import com.student.education.service.AttentionStudentService;
import com.student.education.service.CheckWorkService;
import com.student.education.to.UserTo;
import com.student.education.vo.UserQueryVo;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 辅导员/老师 关注学生
 */
@RestController
@RequestMapping("/attentionStudent")
public class AttentionStudentController {

    @Resource
    private AttentionStudentService attentionStudentService;


    /**
     * 将学生列表学生加入到关注学生里
     * @param tId
     * @param sId
     * @return
     */
    @GetMapping("/addStudents")
    public CommonResult<String> addStudents(Integer tId, Integer sId) {
        if (attentionStudentService.addStudents(tId,sId)){
            return CommonResult.success("关注成功");
        }
        return CommonResult.error("关注失败:已关注");
    }

    /**
     * 查询我关注的学生
     * @param vo
     * @return
     */
    @PostMapping("/queryAllMyStudents")
    public CommonResult<CommonPage<UserTo>> queryAll(@RequestBody UserQueryVo vo) {
        return CommonResult.success(attentionStudentService.queryAll(vo));
    }

    /**
     * 删除我关注的学生
     * @param userId
     * @param id
     * @return
     */
    @GetMapping("/deleteAttentionStudents")
    public CommonResult<String> deleteAttentionStudents(Integer userId,Integer id) {
        if (attentionStudentService.deleteAttentionStudents(userId,id)){
            return CommonResult.success("删除成功");
        }
        return CommonResult.error("删除失败");
    }

}
